<?php

namespace App\Admin\Extensions\Form;

use Encore\Admin\Form\Field;


class EidtCode extends Field
{
    protected $view = 'admin.form.editcode';

    protected static $css = [
        // 'http://zhuoke.zhiyuanch.com/skin/manager/highlight/styles/railscasts.css',
    ];

    protected static $js = [
        '/vendor/laravel-admin/ace/ace.js',
    ];

    public function render()
    {
		$id = $this->id;
        $this->script = <<<EOT
$(function () {
           var editor = ace.edit("$id");
		   window.editor = editor;
		   editor.setTheme("ace/theme/tomorrow_night");
		   editor.on("blur", function(e){
			   console.log(htmlspecialchars(editor.getValue()));
			   $('#value-$id').html(htmlspecialchars(editor.getValue()));
		   })
})

EOT;

        return parent::render();
    }
}